<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>删除和替换节点</title>
	</head>
	<body>
		<ul>
			<li>
			<img src="chapter03/prictice02/images/dog.jpg" />
			<p><input type="button" value="删除我吧" onclick="del(this)"/></p>
			</li>
			<li>
			<img src="chapter03/prictice02/images/mai.jpg" />
			<p><input type="button" value="换换我吧" onclick="rep(this)"/></p>
			</li>
		</ul>
		<script>
			function del(e){
				var e1=e.parentNode.previousElementSibling;
				e1.parentNode.removeChild(e1);
			}
			function rep(e){
				var e1=e.parentNode.previousElementSibling;
				var e2=document.createElement("img");
				e2.setAttribute("src","chapter03/prictice02/images/dog.jpg");
				e1.parentNode.replaceChild(e2,e1);
			}
		</script>
	</body>
</html>
